import socket

def socks5(s): # see rfc1928
    s.recv(65536) # recv version
    s.send(chr(5) + chr(0)) # send ver, method
    req = s.recv(65536) # recv req

ss = socket.socket() # create a socket object
ss.bind(('', 1080)) # bind 1080 port
ss.listen(0) # listen
while True:
    s = ss.accept()[0] # accept client
    socks5(s)
